package com.xfcy.content.api;

import com.xfcy.content.model.dto.AddCourseTeacherDto;
import com.xfcy.content.model.dto.EditCourseTeacherDto;
import com.xfcy.content.model.po.CourseTeacher;
import com.xfcy.content.service.CourseTeacherService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 晓风残月Lx
 * @date 2023/6/16 19:09
 */
@RestController
@Slf4j
public class CourseTeacherController {

    @Resource
    private CourseTeacherService courseTeacherService;


    @ApiOperation("查询老师信息")
    @GetMapping("/courseTeacher/list/{courseId}")
    public CourseTeacher getCourseTeacher(@PathVariable Long courseId) {
        return courseTeacherService.getCourseTeacher(courseId);
    }

    @ApiOperation("添加老师信息")
    @PostMapping("/courseTeacher")
    public CourseTeacher addCourseTeacher(@RequestBody @Validated AddCourseTeacherDto addCourseTeacherDto) {
        return courseTeacherService.addCourseTeacher(addCourseTeacherDto);
    }

    @ApiOperation("修改老师信息")
    @PutMapping("/courseTeacher")
    public CourseTeacher editCourseTeacher(@RequestBody @Validated EditCourseTeacherDto editCourseTeacherDto) {
        return courseTeacherService.editCourseTeacher(editCourseTeacherDto);
    }

    @ApiOperation("删除老师信息")
    @DeleteMapping("/courseTeacher/course/{courseId}/{teacherId}")
    public void deleteTeacher(@PathVariable Long courseId, @PathVariable Long teacherId) {
        courseTeacherService.deleteTeacher(courseId, teacherId);
    }

}
